package com.situ.day9;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;

public class Demo {

	@Test
	public void test1() {
		ArrayList<Student> list = new ArrayList<Student>();
		Student student1 = new Student(1, "zhangsan1", 23, "java");
		Student student2 = new Student(2, "zhangsan2", 23, "java");
		Student student3 = new Student(3, "zhangsan3", 23, "java");
		Student student4 = new Student(4, "zhangsan4", 23, "java");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		list.add(student4);
		list.add(student4);
		for (Student student : list) {
			System.out.println(student);
		}
		System.out.println("--------------");

		HashSet<Student> set = new HashSet<Student>();
		set.add(student1);
		set.add(student2);
		set.add(student3);
		set.add(student4);
		set.add(student4);
		for (Student student : set) {
			System.out.println(student);
		}
	}

	@Test
	public void test2() {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("CN", "中华人民共和国");
		map.put("US", "美利坚合众国");
		String value1 = map.get("CN");
		System.out.println(value1);
		String value2 = map.get("US");
		System.out.println(value2);
		System.out.println("------------");

		Set<Entry<String, String>> set = map.entrySet();
		for (Entry<String, String> entry : set) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("key:" + key + ",value:" + value);
		}
		System.out.println("----------");
		Set< String> keySet = map.keySet(); //key集合
		for (String key : keySet) {
			String value = map.get(key);
			System.out.println("key:" + key + ",value:" + value);
		}		
	}
}
